// import fetch from 'isomorphic-fetch'

export const GET_USER = 'GET_USER'
export const PUSH_USER = 'PUSH_USER'
export const ADD_USERS = 'ADD_USERS'
export const PUSH_USERS = 'PUSH_USERS'

export function getUser() {
	return {
			type: "GET_USER",
	    	user:{name:"shichenda",age:24}
		};
}

export function pushUser() {
  return {
    type: "PUSH_USER",
    user:{name:"shichenda",age:25}
  }
}

function PostUsers(jsonDate){
	console.log(jsonDate);
	return{
		type : "ADD_USERS",
		users: jsonDate.resources
	}
}

export function getUsers(){
	 return dispatch => {
	    return fetch(`http://115.159.78.180:8090/Audstat/user/list.json?page=1&size=10`)
	      .then(response => response.json())
	      .then(json => dispatch(PostUsers(json)))
	  }
}
